﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PixelsGraph;

namespace CompareInFunction
{
    [TestClass]
    public class FunctionTests
    {
        [TestMethod]
        public void CompareEqual2Function()
        {
            Function temp1 = new Function();
            temp1.SetFunctionParamsAndType(LoaiHam.BacNhat, new float[] { 1, 2 });
            Function temp2 = new Function();
            temp2.SetFunctionParamsAndType(LoaiHam.BacNhat, new float[] { 1, 2 });
            Assert.AreEqual(temp1 == temp2, true);
        }

        [TestMethod]
        public void CompareNotEqual2Function()
        {
            Function temp1 = new Function();
            temp1.SetFunctionParamsAndType(LoaiHam.BacNhat, new float[] { 1, 2 });
            Function temp2 = new Function();
            temp2.SetFunctionParamsAndType(LoaiHam.BacNhat, new float[] { 1, 3 });
            Assert.AreEqual(temp1 != temp2, true);
        }

        [TestMethod]
        public void ComapreEqualFunctionWithNull()
        {
            Function temp1 = new Function();
            temp1.SetFunctionParamsAndType(LoaiHam.BacNhat, new float[] { 1, 2 });
            Assert.AreEqual(temp1 == null, false);
        }

        [TestMethod]
        public void ComapreNotEqualFunctionWithNull()
        {
            Function temp1 = new Function();
            temp1.SetFunctionParamsAndType(LoaiHam.BacNhat, new float[] { 1, 2 });
            Assert.AreEqual(temp1 != null, true);
        }

        [TestMethod]
        public void ComapreEqualNullFunctionWithNull()
        {
            Function temp1 = null;
            Assert.AreEqual(temp1 == null, true);
        }

        [TestMethod]
        public void ComapreNotEqualNullFunctionWithNull()
        {
            Function temp1 = null;
            Assert.AreEqual(temp1 != null, false);
        }

        [TestMethod]
        public void CheckEqualsMethodWithFunction()
        {
            Function temp1 = new Function();
            temp1.SetFunctionParamsAndType(LoaiHam.BacNhat, new float[] { 1, 2 });
            Function temp2 = new Function();
            temp2.SetFunctionParamsAndType(LoaiHam.BacNhat, new float[] { 1, 2 });
            Assert.AreEqual(temp1.Equals(temp2), true);
        }

        [TestMethod]
        public void CheckEqualsMethodWithFunction2()
        {
            Function temp1 = new Function();
            temp1.SetFunctionParamsAndType(LoaiHam.BacNhat, new float[] { 1, 2 });
            Function temp2 = new Function();
            temp2.SetFunctionParamsAndType(LoaiHam.BacNhat, new float[] { 1, 3 });
            Assert.AreEqual(temp1.Equals(temp2), false);
        }

        [TestMethod]
        public void CheckEqualsMethodWithNullFunction()
        {
            Function temp1 = new Function();
            temp1.SetFunctionParamsAndType(LoaiHam.BacNhat, new float[] { 1, 2 });
            Assert.AreEqual(temp1.Equals(null), false);
        }
    }
}
